//
//  XMGCommentView.m
//  BuDeJie19
//
//  Created by hjj on 2016/12/3.
//  Copyright © 2016年 hjjuny. All rights reserved.
//
#import "XMGCommentView.h"
#import "XMGCommentItem.h"
#import "XMGUserItem.h"
#import "XMGTopicItem.h"
@interface XMGCommentView ()
@property (weak, nonatomic) IBOutlet UILabel *totalView;
@property (weak, nonatomic) IBOutlet UIView *voiceView;
@property (weak, nonatomic) IBOutlet UILabel *nameView;
@property (weak, nonatomic) IBOutlet UIButton *voiceButton;

@end

@implementation XMGCommentView
/*
    以后只要界面没有问题，但是莫名其妙报一些约束冲突，这时候考虑自动拉伸属性(iOS6)
 
 */

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    // 取消自动拉伸属性
    self.autoresizingMask = UIViewAutoresizingNone;
}
- (void)setItem:(XMGTopicItem *)item
{
    [super setItem:item];
    
    if (item.topComment.content.length) {
        // 文字
        _voiceView.hidden = YES;
        _totalView.hidden = NO;
        
        _totalView.text = item.topComment.totalContent;
        
    } else {
        // 音频
        _voiceView.hidden = NO;
        _totalView.hidden = YES;
        
        _nameView.text = item.topComment.user.username;
        [_voiceButton setTitle:item.topComment.voicetime forState:UIControlStateNormal];
    }
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
